package game;
import java.io.Serializable;

/**
 * Point represents the coordinate of each point in Field.
 * 
 * @author Sarun Wongtanakarn 5510546166
 * @author Apiwat Jierakulpanit 551054212
 * @Version 2013.04.27
 */
public class Point implements Serializable{
	
	public final int X;
	public final int Y;
	
	/**
	 * Creates a new Point.
	 * 
	 * @param x coordinate in x-axis of this point.
	 * @param y coordinate in y-axis of this point.
	 */
	public Point(int x, int y) {
		X = x;
		Y = y;
	}

	/**
	 * Determines whether this point and obj is equal or not.
	 * 
	 * @param obj Object to be compared.
	 * @return true if they have the same coordinate; false otherwise.
	 */
	@Override
	public boolean equals(Object obj) {
		if (obj == null) return false;
		if (!(obj instanceof Point)) return false;
		Point p = (Point) obj;
		return X == p.X && Y == p.Y;
	}

	/**
	 * Returns hashCode of this point.
	 * @return hashCode of this point.
	 */
	@Override
	public int hashCode() {
		String s = X + "," + Y;
		return s.hashCode();
	}
	
	
}
